package com.technology.education.ui.common.information

import android.os.Bundle
import com.technology.education.R
import com.technology.education.data.AppData
import com.technology.education.data.SpKeys
import com.technology.education.databinding.ActivityCompleteInfoBinding
import com.technology.education.databinding.ActivityCompleteWithdrawBinding
import com.technology.education.ext.getMiddleColor
import com.technology.education.ext.saveData
import com.technology.education.ui.market.MainMarketActivity
import com.technology.education.ui.student.MainStudentActivity
import com.technology.education.ui.teacher.MainTeacherActivity
import me.hgj.jetpackmvvm.base.activity.BaseVmDbActivity
import me.hgj.jetpackmvvm.ext.lifecycle.KtxActivityManger
import me.hgj.jetpackmvvm.util.startActivity

/**
 * 完善提现信息
 */
class CompleteWithdrawActivity :
    BaseVmDbActivity<CompleteWithdrawViewModel, ActivityCompleteWithdrawBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.vm = mViewModel
        mViewModel.type=intent.getIntExtra("type",0)
        mDatabind.tvLogin.text = getMiddleColor("已有账号？立即去", "登录", "", getColor(R.color.theme_color))
    }

    override fun showLoading(message: String) {
    }

    override fun dismissLoading() {
    }

    override fun createObserver() {
        mViewModel.result.observe(this) {
            if (it) {
                if (mViewModel.type==0){
                    saveData(SpKeys.IS_LOGIN, true)
                    KtxActivityManger.finishAllActivity()
                    if (AppData.MEMBER_TYPE=="1")
                    {
                        startActivity(MainTeacherActivity::class)
                    }else{
                        startActivity(MainMarketActivity::class)
                    }
                }else{
                    onBackPressed()
                }

            }
        }
    }

    inner class ClickProxy {
        fun goLogin() {
            onBackPressed()
        }

    }
}